﻿using ASmile.Com;
using ASmile.Com.Search;
using ASmile.DBModel;
using ASmile.Extend;

namespace ASmile.Win.DaBLL
{
    class SearchBLL : BLLBase, ISearchBLL
    {
        public SearchBLL()
        { }

        protected override string ControllerName => "SysManage/Search";

        /// <summary>
        /// 获取列信息
        /// </summary>
        [WebApi("SysManage/GridView", "GetColumnInfo")]
        public ApiResultList<Sys_GridColumn> GetColumns(Com.GridView.ArgGetList arg)
        {
            if (arg.DgvName.IsEmpty()) arg.DgvName = "dgv";
            return GetResultList<Sys_GridColumn>(arg);            
        }
        /// <summary>
        /// 获取默认记录
        /// </summary>
        public ApiResult<Sys_ADRecord> GetDefRecord(ArgRecordSearch arg)
        {
            if (arg.DgvName.IsEmpty()) arg.DgvName = "dgv";
            var ret = GetResult<Sys_ADRecord>(arg);
            return ret;
        }
        /// <summary>
        /// 指定记录Id更新缺省记录，用于无修改的搜索记录
        /// </summary>
        public ApiResult SaveDefRecord(ArgSaveRecord arg)
        {
            return GetResult(arg);
            //var ret = HttpRequest<ApiResult>(new { RecordId = recordId, Details = details });
            //return ret;
        }
        /// <summary>
        /// 保存新的记录
        /// </summary>
        public ApiResult<string> SaveRecord(ArgSaveRecord arg)
        {
            return GetResult<string>(arg);
        }
        /// <summary>
        /// 获取搜索记录条件明细
        /// </summary>
        public ApiResultList<Sys_ADRecord_Detail> GetRecordDetail(ArgMainId arg)
        {
            return GetResultList<Sys_ADRecord_Detail>(arg);
        }
        /// <summary>
        /// 获取指定的所有保存的记录
        /// </summary>
        public ApiResultList<Sys_ADRecord> GetRecordList(ArgRecordSearch arg)
        {
            if (arg.DgvName.IsEmpty()) arg.DgvName = "dgv";
            var ret = GetResultList<Sys_ADRecord>(arg);
            return ret;
        }
        /// <summary>
        /// 删除搜索记录及明细
        /// </summary>
        public ApiResult DelRecord(Sys_ADRecord record)
        {
            return GetResult(record);
        }
        /// <summary>
        /// 更新记录
        /// </summary>
        public ApiResult<string> UpdateRecord(Sys_ADRecord record)
        {
            return GetResult<string>(record);
        }
    }
}